// support functions for loading data from the network


function openCloseFoldedItems(index, model) {
    var activity = model.get(index);
    var nextActivity = model.get(++index);

    while (nextActivity.user_name == activity.user_name) {
        if (nextActivity.open) {
            model.setProperty(index, "open", false);
        } else {
            model.setProperty(index, "open", true);
        }
        if (++index == model.count) { break; }
        nextActivity = model.get(index);
    }
}


function reloadModel(jsonModel, theList) {
    jsonModel.clear();
    reload(jsonModel, theList, 1);
}


function checkLoadingSpinner() {
    window.toBeLoaded--;
    if (window.toBeLoaded == 0) {
        imageLoading.visible = false;
        return true;
    }
    return false;
}

function reloadAll() {
    window.toBeLoaded = 4
    activityList.state = "loadingActivities"
    spotsList.state = "loadingSpots"
    friendsList.state = "loadingFriends"
    //myCitiesList.state = "loadingMyCities"
    suggestedSpotsList.state = "loadingSuggestedSpots"
}
